// render.h : contains the definition of the render component. This component
// is responsible for rendering the object and displaying it when called for
//$Id: Render.h 46 2009-09-24 22:38:34Z brwarner2 $

#pragma once
#include "component.h"

//Render component class
class CRender :
	public IComponent
{
public:
	CRender(void);
	virtual ~CRender(void);

	//Initialization
	void Init( const ParameterList &params );

	//Component ID
	static const ComponentID COMPONENT_ID = 2;

	//Game monkey registration function
	static void RegisterGM( gmMachine* );

	//Handler for GM function calls
	int GMCall( gmThread*, const std::string& name );

	//Get component ID
	ComponentID GetComponentID(void) { return COMPONENT_ID; }

	//Factory function
	static IComponent* Factory(void) { return new CRender(); }

	//Destruct function
	static void Destruct( IComponent* pEnt ) { delete (pEnt); }

	//Message function
	void Message( MessageID message, const boost::any& arg = 0);

	//Gets information from the loaded image
	float GetImageInformation( const std::string& name );

	//Loads an info file into the component
	void LoadInfoFile( const std::string& filename );

private:
	//Texture for rendering
	bug::render::SkinPointer m_skin;

	//Additional image information
	std::map< std::string, std::string > m_imageInfo;

	//Number of horizontal frames
	unsigned int m_nNumFrames;

	//Size of a frame
	unsigned int m_nFrameSize, m_nFrameHeight;

	//Frames per second
	unsigned int m_nFPS;

	//Current animation frame
	unsigned int m_nCurrentFrame;

	//Playing
	bool m_bPlaying;

	//Time since last frame change
	float m_fLastFrame;
};
